package com.hualan.zhsq.service.impl.car;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hualan.zhsq.entity.car.PaymentMethod;
import com.hualan.zhsq.mapper.car.PaymentMethodMapper;
import com.hualan.zhsq.service.car.PaymentMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName PaymentMethodServiceImpl
 * @Description 支付方式serviceImpl
 * @Author ZheRan
 * @Date 2025年08月04日 下午7:29
 * @Version 1.0
 */
@Service("paymentMethodService")
public class PaymentMethodServiceImpl  implements PaymentMethodService {

    @Autowired
    private PaymentMethodMapper paymentMethodMapper;

    @Override
    public int add(PaymentMethod entity) {
        return paymentMethodMapper.insert(entity);
    }

    @Override
    public int edit(PaymentMethod entity) {
        return paymentMethodMapper.updateById(entity);
    }

    @Override
    public int remove(Integer id) {
        return paymentMethodMapper.deleteById(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return paymentMethodMapper.deleteBatchIds(List.of(ids));
    }

    @Override
    public List<PaymentMethod> find() {
        return paymentMethodMapper.selectList(null);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, PaymentMethod entity) {
        Page<PaymentMethod> page = new Page<>(pageNum, pageSize);
        Page<PaymentMethod> paymentMethodPage = paymentMethodMapper.selectPage(page, null);
        Map<String, Object> map = new HashMap<>();
        map.put("list",paymentMethodPage.getRecords());
        map.put("total", paymentMethodPage.getTotal());
        map.put("size", paymentMethodPage.getSize());
        return map;
    }

    @Override
    public PaymentMethod findById(Integer id) {
        return paymentMethodMapper.selectById(id);
    }
}
